home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / tool6v12 / demoinp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-07-01  |  2.5 KB  |  88 lines

  1. Program DemoInput;
  2.  
  3. { Purpose....... Demonstrates the use of the following units: win, screen,
  4.                  strings, datetime, cursor and input.
  5.   Comments...... None
  6.   Author........ Thayne Breetzke
  7.   Date.......... 22 March 1994                                               }
  8.  
  9. Uses
  10.   Crt,
  11.   Dos,
  12.   Windows,
  13.   Screen,
  14.   Strings,
  15.   DateTime,
  16.   Cursor,
  17.   Input;
  18.  
  19. Var
  20.   InputString: String;
  21.   Key        : Char;
  22.   Extended,
  23.   HelpOn     : Boolean;
  24.   CState     : CStateRec;
  25.  
  26. {$F+}
  27. Procedure UpdateProc(Var Key: Char; Var Extended: Boolean; UpdateVar: Word);
  28.  
  29. Var
  30.   Hour,
  31.   Min,
  32.   Sec,
  33.   Sec100 : Word;
  34.  
  35. Begin
  36.   GetTime(Hour,Min,Sec,Sec100);
  37.   WriteWinXY(72,25,TimeStr(Hour,Min,Sec,0,':'),0+7*16);
  38.   If (Key = #59) and not HelpOn then
  39.     Begin
  40.       HelpOn := True;
  41.       SaveCursor(InsertKey,CState);
  42.       CursorOff;
  43.       OpenWindow(7,8,74,21,' Help ',' Press Esc to close this help window ',DoubleFrame,15+4*16,15+4*16,True);
  44.       WriteMem(9,10,'No help available');
  45.       GetKey(Key,Extended,[#27],[],True,True,UpdateProc,0);
  46.       CloseWindow;
  47.       RestoreCursor(CState);
  48.       Key := #0;
  49.       HelpOn := False
  50.     end
  51. end;
  52. {$F-}
  53.  
  54. Begin
  55.   TextAttr := 7;
  56.   CursorOff;
  57.   InputString := '';
  58.   HelpOn := False;
  59.   ClearArea(1,1,80,25,7,'▒');
  60.   DrawBox(4,2,77,4,'','',DoubleFrame,15+1*16,14+1*16,True);
  61.   WriteMem(5,3,Center('The "Complete" Borland Turbo Pascal 6.0 Toolbox',72));
  62.   WriteWinXY(1,25,CopyChar(' ',80),112);
  63.   WriteWinXY(2,25,'F1',4+7*16);
  64.   WriteWinXY(5,25,'Help',0+7*16);
  65.   OpenWindow(11,10,70,17,'',' Press Ctrl-Enter to continue ',SingleFrame,15+7*16,15+7*16,True);
  66.   WriteWinXY(19,12,'Using GetKey routine to scan for keypresses',0+7*16);
  67.   WriteWinXY(15,14,'Last key pressed: ',0+7*16);
  68.   WriteWinXY(15,15,'Was it extended?: ',0+7*16);
  69.   Repeat
  70.     GetKey(Key,Extended,[#0..#255],[#0..#255],True,True,UpdateProc,0);
  71.     WriteWinXY(33,14,Key+' (#'+NumToStr(Ord(Key),0,0,False)+') ',0+7*16);
  72.     If Extended then
  73.       WriteWinXY(33,15,'Yes',0+7*16)
  74.     else
  75.       WriteWinXY(33,15,'No ',0+7*16)
  76.   until Key = #10;
  77.   ClearArea(12,11,69,16,0+7*16,' ');
  78.   WriteWinXY(20,12,'Using ReadString routine to read a string',0+7*16);
  79.   WriteWinXY(15,14,'Enter a string:',0+7*16);
  80.   ReadString(InputString,31,14,50,25,[#32..#126],False,[#13,#10,#27],[#45],
  81.              Key,Extended,True,False,112,UpdateProc,0);
  82.   CloseWindow;
  83.   CursorOn(False);
  84.   ClrScr;
  85.   Writeln('As entered: '+InputString);
  86.   Writeln('Upper case: '+Upper(InputString));
  87.   Writeln('Lower case: '+Lower(InputString))
  88. end.